//
//  GSYTableViewCell.m
//  GoTraveling
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "GSYTableViewCell.h"
#import "GSYImageView.h"
@interface GSYTableViewCell()
@property (nonatomic, retain) UIImageView *headImage;

@property (nonatomic, retain) UILabel *nameLabel;

@property (nonatomic, retain) UILabel *contentLabel;

@property (nonatomic, retain) UILabel *distance;

@end

@implementation GSYTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {

    GSYImageView *occupyImage = [[GSYImageView alloc] initWithFrame:CGRectMake(20, 10, 120, 120)];
    occupyImage.layer.cornerRadius = 5;
    occupyImage.layer.masksToBounds = YES;
    [self.contentView addSubview:occupyImage];
    
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 120, 120)];
    self.headImage.contentMode = UIViewContentModeScaleAspectFill;
    self.headImage.layer.cornerRadius = 5;
    self.headImage.layer.masksToBounds = YES;
    [self.contentView addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 10, WIDTH - 170, 30)];
    self.nameLabel.font = [UIFont systemFontOfSize:22 weight:0.2];
    self.nameLabel.textColor = [UIColor colorWithRed:0.24 green:0.24 blue:0.25 alpha:1];
     [self.contentView addSubview:self.nameLabel];
    
    self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 65, WIDTH - 170, 50)];
    self.contentLabel.textColor = [UIColor colorWithRed:0.69 green:0.69 blue:0.67 alpha:1];
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.contentLabel];
    
    
    self.distance = [[UILabel alloc] initWithFrame:CGRectMake(150, 115, WIDTH - 150, 20)];
    self.distance.textColor = [UIColor colorWithRed:0.69 green:0.69 blue:0.67 alpha:1];
    self.distance.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.distance];
    

}

-(void)setOther:(GSYOther *)other
{
    if (_other != other) {
        
        _other = other;
    }

  [self.headImage sd_setImageWithURL:[NSURL URLWithString:self.other.cover]];
    
    self.nameLabel.text = self.other.name;
    
    self.contentLabel.text = self.other.descriptions;
    self.distance.text = [NSString stringWithFormat:@"%@ 人去过", self.other.visited_count];

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
